﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TR.Domain.Entity;
using TR.Domain.Entity.BsItemType;
using TR.Domain.Entity.JH;
using TR.Domain.Entity.WHOB;

namespace TR.EFCore
{
    public class MyContext : DbContext
    {
        public string conStr = "Data Source=rm-cn-omn3o8dvy000aako.sqlserver.rds.aliyuncs.com, 1433;Initial Catalog=TR;User ID=l_123;Password=Ff123456;Encrypt=False;";
        public MyContext(DbContextOptions<MyContext> options) : base(options)
        {
            //读取ui的配置信息
        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //输出ef日志
            optionsBuilder.LogTo(msg =>
            {
                if (!msg.Contains("CommandExecuting"))
                {
                    return;
                }
                Console.WriteLine(msg);
            });
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {

            //读取所有的配置类
            modelBuilder.ApplyConfigurationsFromAssembly(this.GetType().Assembly);
        }

        //声明webApi需要 引用 cs类实现AppService文件中的对应方法
        public DbSet<Cs> Cs { get; set; }

        //编码规则表
        public DbSet<sys_Encode> Senc { get; set; }

        //供应商表
        public DbSet<bs_Supply> bs_Supply { get; set; }

        //财务表
        public DbSet<bs_Finance> bs_Finance { get; set; }

        //进货订单表
        public DbSet<wh_Buy_Order_h> wh_Buy_Order_H { get; set; }

        //进货详情表
        public DbSet<wh_orderbuy_d> wh_orderbuy_d {  get; set; }

        //进货订单详情查询
        public DbSet<JHXQ> JHXQ { get; set; }

        //进货订单表
        public DbSet<wh_Buy_Order_h> Wboh { get; set; }

        //进货订单信息表
        public DbSet<WHOB_Select> WHOM_Select { get; set; }

        //用户信息表
        public DbSet<rbac_User> rbac_User { get; set; }

        //货品类型表
        public DbSet<bs_Item_Type> bs_Item_Type {  get; set; }

        //货品信息表
        public DbSet<bs_Item> bs_Item { get; set; }
    }
}
